#!/bin/bash

case "$1" in
    start|up)
        echo "启动课程作业系统..."
        docker-compose up -d
        echo "系统已启动，访问地址: http://localhost:25612"
        ;;
    stop|down)
        echo "停止课程作业系统..."
        docker-compose down
        echo "系统已停止"
        ;;
    restart)
        echo "重启课程作业系统..."
        docker-compose restart
        echo "系统已重启"
        ;;
    rebuild)
        echo "重新构建并启动课程作业系统..."
        docker-compose down
        docker-compose build --no-cache
        docker-compose up -d
        echo "系统已重新构建并启动"
        ;;
    logs)
        echo "查看系统日志..."
        docker-compose logs -f
        ;;
    status)
        echo "查看系统状态..."
        docker-compose ps
        ;;
    *)
        echo "课程作业系统 Docker 管理脚本"
        echo "用法: $0 {start|stop|restart|rebuild|logs|status}"
        echo ""
        echo "命令说明:"
        echo "  start/up    - 启动系统"
        echo "  stop/down   - 停止系统"
        echo "  restart     - 重启系统"
        echo "  rebuild     - 重新构建并启动"
        echo "  logs        - 查看实时日志"
        echo "  status      - 查看运行状态"
        exit 1
        ;;
esac 